All Questions
Tagged with react-contextreact-router
126 questions
1vote
1answer
34views
Why attendence Context fetching again on navigation back to the teacherattend component?
I need to use attendance data often on my website, So I make it as utility as below: import React, { useState, useEffect, useMemo, useCallback, createContext } from 'react'; import { ...
2votes
1answer
66views
How can I prevent the accessibility of a react component once the user has been logged out of the private route in react?
I have been working on really simple react pages just to clear my concepts. In this, i have a simple authentication method by storing the login info in users.json file (This is just for the sake of ...
0votes
0answers
44views
The redirection to the main page after login or registration only works after the second form submission (only on Mobile)
In my Group Counter App, I implemented authorization functionality. Earlier, I had a problem with authorization on PC, and I created a question where I solved my problem. However, now that I have ...
0votes
1answer
94views
redirection to the main page after logIn or registration doesn't working. firebase, private route, email authentication [closed]
I encountered an issue that I can't solve. In my handleLogIn function within the ContextProvider component, I am using the useNavigate hook to redirect the page to "/" if the user ...
1vote
0answers
17views
Issue with manual url path acessibility with firebase, router and contextAPI [duplicate]
I want to access routes manually by typing the URL address in the browser if the user is logged in. If the user is not logged in, I want to redirect the page to the login page. Additionally, I want ...
0votes
1answer
48views
context value is not being updated on time
context.tsx import { PropsWithChildren, createContext, useContext, useState } from "react"; import auth_svc from "../services/authServices"; import { Result, message } from "...
0votes
0answers
12views
How can I redirect already logged user to home page in React? [duplicate]
I need help trying to redirect already logged user(using cookies) to the homepage, whenever the user tries to go to login page. Here is what I'm trying to do I am using useAuth, hook that just calls ...
0votes
1answer
2kviews
How to pass props through outlet context and retrieve props from useOutletContext() inside child component
I try to use context inside Outlet react-dom-router component and retrieve props through useOutletContext() inside outlet children component as below tsx // inside parent component <Outlet context={...
0votes
1answer
156views
createBrowserRouter remounts whole page when context variable changes state [duplicate]
My entire site is wrapped inside a context to handle global variables. This used to work with <BrowserRouter>. When a variable changed it made everything to refresh but not remount. Might be ...
1vote
1answer
30views
Problem with React Router - page renders before effect sets state with api call response
I am having a strange problem with my React application. It is a mock vinyl shop and now I am working on the "previous orders" functionality. I am sending a GET request with my token to my ...
0votes
1answer
51views
React Context Re-rendering Issue when Using Context for User Login [duplicate]
I am encountering an issue with React context while implementing user login functionality on my website. Users can log in as dummy users, and I've implemented this using React contexts. However, after ...
1vote
2answers
82views
React Compiles to Blank White Page with Error Handling Router using react-router-dom v6
My React application compiles properly but only serves a white page. When inspecting in the browser, the following can be seen. Error from inspect page I noticed this error emerging after adding ...
1vote
1answer
85views
Show respective page when user is logged in
My problem is that I display the respective page depending on whether a user is logged in or not. If the user is logged off, he should be forwarded to the login page and not be able to access any ...
2votes
1answer
1kviews
Proper way to use Route alongside Context
I know how to use Routes. I know how to use Contexts. I do not know how to use them together. I have an application with Routes function App() { return ( <Routes> <...
3votes
1answer
878views
Browser Router resetting state/context value to default regardless of it being placed outside of its scope
I'm trying to create a simple page using Browser Router. Navigation consist of 7 categories, 6 of which link to "/category/:categoryName", and 1 links back to root. I need to keep track of ...